////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   USER
// AUTHOR           :   Victor Zheng 
// DATE CREATE      :   2006/02/01
// DESCRIPTION      :   a MAINTENANCE FORM file for the function, USER
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/02/01   Victor Zheng    1.0                 source is generated.
// 2006/06/20   William Xu      1.0                 BugZilla #6277
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.app.admin.userSetup.web;

import java.util.ArrayList;
import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.erp.app.common.ProjectConstants;
import com.erp.app.common.util.ProjectCommonUtil;
import com.erp.app.setup.codeSetup.pk.CodeHdrPk;

import com.erp.app.util.web.ActionErrorUtil;
import com.erp.app.util.web.BeanValidator;
import com.erp.app.util.web.MultiRowValidator;
import com.erp.framework.controller.form.MultiRow;
import com.erp.framework.controller.form.SimpleMaintStyleForm;


/**
* <p>A <strong>MaintenanceForm</strong> is a JavaBean which provides property
* getter and setter methods for all of the bean properties, and implements
* <code>Serializable</code>, as required by the JavaBean specification
* The main purpose for this bean is to get the user input
* from the web browsers.
*
* @author          Victor Zheng 
* @version 1.0     2006/02/01
* @since           FrameWork 1.0
*
*/
public class UserMaintenanceForm extends SimpleMaintStyleForm {

	//Header Attributes (DB Table Name: T_USER)
	private String userCode;                         //DB Column Name: USER_CODE
	private String companyCode;                      //DB Column Name: COMPANY_CODE
	private String userName;                         //DB Column Name: USER_NAME
	private String email;                            //DB Column Name: EMAIL
	private String password;                         //DB Column Name: PASSWORD
	private String roleGroupId;                      //DB Column Name: ROLE_GROUP_ID
	private String groupLevel;                       //DB Column Name: GROUP_LEVEL
	private String activation;                       //DB Column Name: ACTIVATION
	private String createUser;                       //DB Column Name: CREATE_USER
	private String createDate;                       //DB Column Name: CREATE_DATE
	private String updateUser;                       //DB Column Name: UPDATE_USER
	private String updateDate;                       //DB Column Name: UPDATE_DATE
	private String userGroupCode;                    //DB Column Name: USER_GROUP_CODE
	private String dept;                             //DB Column Name: DEPT
	private String contentType;                      //DB Column Name: CONTENT_TYPE
	private byte[] signature;                        //DB Column Name: SIGNATURE
	private String salesmanFlag;
	private String qaHandlerFlag;                    //DB Column Name: QA_HANDLER
	private String qcHandlerFlag;                    //DB Column Name: QC_HANDLER
	private String approverFlag;                     //DB Column Name: APPROVER 
	private String gmmFlag;                          //DB Column Name: GMM
	private String userDivision;                         //DB Column Name: DIVISION
    private String hdrCompanyType = "";                                                                //DB Column Name: COMPANY_TYPE
    private String hdrNtTeam = "";                                                                     //DB Column Name: NT_TEAM
    private String hdrCustCode = "";                                                                   //DB Column Name: CUST_CODE

	
	//Child Attributes (DB Table Name: T_USER_GMM)
	private String[] gmmCompanyCode;                 //DB Column Name: COMPANY_CODE
	private String[] gmmUserCode;                    //DB Column Name: USER_CODE
	private String[] gmmLineNo;                      //DB Column Name: LINE_NO
	private String[] gmmDivision;                    //DB Column Name: DIVISION
	private String[] gmmDcInd;                       //DB Column Name: DC_IND
	private String[] gmmDcDate;                      //DB Column Name: DC_DATE
	                              
	//Child Attributes (DB Table Name: T_USER_SIGNATURE)
	private String[] signatureLineNo;                                                                  //DB Column Name: LINE_NO
	private String[] signatureSignatureType;                                                             //DB Column Name: CONTENT_TYPE
	private String[] signatureContentType;                                                             //DB Column Name: CONTENT_TYPE
	private String[] signatureDescription;                                                             //DB Column Name: DESCRIPTION
	private byte[] signatureSignature;                                                                 //DB Column Name: SIGNATURE
	private String[] signatureDcInd;                                                                   //DB Column Name: DC_IND
	private String[] signatureDcDate;                                                                  //DB Column Name: DC_DATE
	
	//Child Attributes (DB Table Name: T_USER_ACCESS_TEAM)
	private String[] accessTeamCode;                                                                   //DB Column Name: ACCESS_TEAM_CODE
	private String[] accessTeamStatus;                                                                   //DB Column Name: STATUS
	private String[] accessTeamDcInd;                                                                        //DB Column Name: DC_IND
	private String[] accessTeamDcDate;                                                                       //DB Column Name: DC_DATE
	
	// Child Attributes (DB Table Name: T_USER_BUYER)
	private String[] buyerCode;                                                                   //DB Column Name: BUYER_CODE
	private String[] buyerStatus;                                                                   //DB Column Name: STATUS
	private String[] buyerDcInd;                                                                        //DB Column Name: DC_IND
	private String[] buyerDcDate;                                                                       //DB Column Name: DC_DATE
	
	//	 Child Attributes (DB Table Name: T_USER_BRAND)
	private String[] brandCode;                                                                   //DB Column Name: BRAND_CODE
	private String[] brandStatus;                                                                   //DB Column Name: STATUS
	private String[] brandDcInd;                                                                        //DB Column Name: DC_IND
	private String[] brandDcDate;                                                                       //DB Column Name: DC_DATE
	
	//	 Child Attributes (DB Table Name: T_USER_NT_TEAM)
	private String[] ntTeamCode;                                                                   //DB Column Name: NT_TEAM_CODE
	private String[] ntTeamStatus;                                                                   //DB Column Name: STATUS
	private String[] ntTeamDcInd;                                                                        //DB Column Name: DC_IND
	private String[] ntTeamDcDate;                                                                       //DB Column Name: DC_DATE

	/**
	* Validate the properties that have been set for this non-HTTP request,
	* and return an <code>ActionErrors</code> object that encapsulates any
	* validation errors that have been found.  If no errors are found, return
	* <code>null</code> or an <code>ActionErrors</code> object with no
	* recorded error messages.
	* <p>
	* The default implementation attempts to forward to the HTTP version of
	* this method.
	*
	* @param      the action errors array
	* @author     Victor Zheng 
	* @since      FrameWork 1.0
	*/
	public void otherValidate(ActionErrors errors) {
    
		validateUser(errors);

//        TableSchema ts = getTs();
//        String validateFeildName = new String();
//
//        validateFeildName = ts.getDisplayWebLabelByObjectId("LBL_USER_USER_CODE");
//        if (CommonUtil.isEmpty(userCode)){
//            ActionErrorUtil.addErrorForGeneralFieldBlank(errors, validateFeildName);            
//        } 
//        
//        validateFeildName = ts.getDisplayWebLabelByObjectId("LBL_USER_ROLE_GROUP_ID");
//        if (CommonUtil.isEmpty(roleGroupId)){
//            ActionErrorUtil.addErrorForGeneralFieldBlank(errors, validateFeildName);
//        } 
//
//        validateFeildName = ts.getDisplayWebLabelByObjectId("LBL_USER_GROUP_LEVEL");
//        if (CommonUtil.isEmpty(groupLevel)){
//            ActionErrorUtil.addErrorForGeneralFieldBlank(errors, validateFeildName);
//        }
//        validateFeildName = ts.getDisplayWebLabelByObjectId("LBL_USER_USER_GROUP_CODE");
//        if (CommonUtil.isEmpty(userGroupCode)){
//            ActionErrorUtil.addErrorForGeneralFieldBlank(errors, validateFeildName);
//        }
	}

	/**
	* Validate the properties that have been set for this non-HTTP request,
	* and return an <code>ActionErrors</code> object that encapsulates any
	* validation errors that have been found.  If no errors are found, return
	* <code>null</code> or an <code>ActionErrors</code> object with no
	* recorded error messages.
	* <p>
	* The default implementation attempts to forward to the HTTP version of
	* this method.
	*
	* @param      errors The errors array that is used for storing validation errors
	* @author     Victor Zheng 
	* @since      FrameWork 1.0
	*/
	public void validateUser(ActionErrors errors) {

		/*
		TableSchema ts = getTs();
		ArrayList userRowList = getMultiRows(UserMaintenanceAction.TAB_IDX_USER);

		for (int i = 0; (userRowList != null) && (i < userRowList.size()); i++) {
			UserRow row = (UserRow) userRowList.get(i);

		}
		*/
		
	}

	/**
	* Validate the properties that have been set for this non-HTTP request,
	* and return an <code>ActionErrors</code> object that encapsulates any
	* validation errors that have been found.  If no errors are found, return
	* <code>null</code> or an <code>ActionErrors</code> object with no
	* recorded error messages.
	* <p>
	* The default implementation attempts to forward to the HTTP version of
	* this method.
	*
	* @param      mapping      the action mapping
	* @param      formIn       the action form
	* @param      request      the http request
	* @param      response     the http response
	* @param      errors       the action errors array
	* @author     Victor Zheng 
	* @since      FrameWork 1.0
	*/
	public void moreValidate(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {
		UserMaintenanceForm form = (UserMaintenanceForm) formIn;
        BeanValidator validator = new BeanValidator();
        validator.validate(mapping, form, request, response, errors);
        validator.validateMultiRows(mapping, form, request, response, errors, 
                form.getMultiRows(UserMaintenanceAction.TAB_IDX_GMM), 
                new MultiRowValidator().setTabLabelObjectId("LBL_TAB_GMM")
                .setLineNumberProperty("gmmLineNo"));

		validator.validateMultiRows(mapping, form, request, response, errors, form.getMultiRows(UserMaintenanceAction.TAB_IDX_SIGNATURE), 
				new MultiRowValidator() {

					

					public void moreValidate(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, 
								HttpServletResponse response, ActionErrors errors, MultiRow row) {}

				}.setTabLabelObjectId("LBL_TAB_SIGNATURE")
			);
	
	
	}

	/**
	* Reset all bean properties to their default state.  This method
	* is called inside the reset() method.
	*
	* @param      mapping The mapping used to select this instance
	* @param      request The servlet request we are processing
	* @author     Victor Zheng 
	* @since      FrameWork 1.0
	*/
	public void otherReset(ActionMapping mapping, HttpServletRequest request) {
		
	}

	/**
	* Converts to a string representing the data in this object.
	* A new <code>String</code> object is allocated and initialized to 
	* contain the character sequence currently represented by this 
	* object. This <code>String</code> is then returned. Subsequent 
	* changes to this object do not affect the contents of the 
	* <code>String</code>. 
	*
	* @return     a string representation of the object.
	* @see        java.lang.Object#toString()
	* @author     Victor Zheng 
	* @since      FrameWork 1.0
	*/
	public String toString() {
		String pkStr = "PK: {userCode = " + this.userCode
			+ "\n, companyCode = " + this.companyCode + "}\n";
		String colStr = "COL: {userName = " + this.userName
			+ "\n, email = " + this.email
			+ "\n, password = " + this.password
			+ "\n, roleGroupId = " + this.roleGroupId
			+ "\n, groupLevel = " + this.groupLevel
			+ "\n, activation = " + this.activation
			+ "\n, createUser = " + this.createUser
			+ "\n, createDate = " + this.createDate
			+ "\n, updateUser = " + this.updateUser
			+ "\n, updateDate = " + this.updateDate
			+ "\n, userGroupCode = " + this.userGroupCode
			+ "\n, dept = " + this.dept
			+ "\n, contentType = " + this.contentType
			+ "\n, qaHandlerFlag = " + this.qaHandlerFlag 
			+ "\n, qaHandlerFlag = " + this.qaHandlerFlag
			+ "\n, approverFlag = " + this.approverFlag 
			+ "\n, gmmFlag = " + this.gmmFlag
			+ "\n, userDivision = " + this.userDivision 
			+ "}\n";
		return "UserMaintenanceForm.toString() (header only) is:\n" + pkStr + colStr;
	}

	////////////////////////////////////////////////////////////////////////////////
	//Generated Accessors (get/set methods) for Header (User)
	////////////////////////////////////////////////////////////////////////////////

	public String getUserCode() {
		return this.userCode;
	}

	public String getCompanyCode() {
		return this.companyCode;
	}

	public String getUserName() {
		return this.userName;
	}

	public String getEmail() {
		return this.email;
	}

	public String getPassword() {
		return this.password;
	}

	public String getRoleGroupId() {
		return this.roleGroupId;
	}

	public String getGroupLevel() {
		return this.groupLevel;
	}

	public String getActivation() {
		return this.activation;
	}

	public String getCreateUser() {
		return this.createUser;
	}

	public String getCreateDate() {
		return this.createDate;
	}

	public String getUpdateUser() {
		return this.updateUser;
	}

	public String getUpdateDate() {
		return this.updateDate;
	}

	public String getUserGroupCode() {
		return this.userGroupCode;
	}

	public String getDept() {
		return this.dept;
	}

	public String getContentType() {
		return this.contentType;
	}

	public byte[] getSignature() {
		return this.signature;
	}
	
	public String getSalesmanFlag() { return salesmanFlag; }

	public String getApproverFlag() {
		return approverFlag;
	}

	public String getQaHandlerFlag() {
		return qaHandlerFlag;
	}
	
	public String getQcHandlerFlag() {
		return qcHandlerFlag;
	}
	
	public String getGmmFlag() {
		return gmmFlag;
	}

	public String getUserDivision() {
		return userDivision;
	}

	public String[] getGmmCompanyCode() {
		return gmmCompanyCode;
	}

	public String[] getGmmDcDate() {
		return gmmDcDate;
	}

	public String[] getGmmDcInd() {
		return gmmDcInd;
	}

	public String[] getGmmDivision() {
		return gmmDivision;
	}

	public String[] getGmmLineNo() {
		return gmmLineNo;
	}

//	public String[] getDtlUpdateDate() {
//		return dtlUpdateDate;
//	}
//
//	public String[] getDtlUpdateUser() {
//		return dtlUpdateUser;
//	}

	public String[] getGmmUserCode() {
		return gmmUserCode;
	}  
	
	public void setUserCode(String userCode) {
		this.userCode = ProjectCommonUtil.toCode(userCode);
	}

	public void setCompanyCode(String companyCode) {
		this.companyCode = companyCode;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setRoleGroupId(String roleGroupId) {
		this.roleGroupId = ProjectCommonUtil.toCode(roleGroupId);
	}

	public void setGroupLevel(String groupLevel) {
		this.groupLevel = groupLevel;
	}

	public void setActivation(String activation) {
		this.activation = activation;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public void setUpdateDate(String updateDate) {
		this.updateDate = updateDate;
	}

	public void setUserGroupCode(String userGroupCode) {
		this.userGroupCode = userGroupCode;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public void setSignature(byte[] signature) {
		this.signature = signature;
	}
	
	public void setSalesmanFlag(String salesmanFlag) { this.salesmanFlag = salesmanFlag; }

	public void setApproverFlag(String approverFlag) {
		this.approverFlag = approverFlag;
	}

	public void setQaHandlerFlag(String qaHandlerFlag) {
		this.qaHandlerFlag = qaHandlerFlag;
	}

	public void setQcHandlerFlag(String qcHandlerFlag) {
		this.qcHandlerFlag = qcHandlerFlag;
	}

	public void setGmmFlag(String gmmFlag) {
		this.gmmFlag = gmmFlag;
	}

	public void setUserDivision(String userDivision) {
		this.userDivision = userDivision;
	}

	public void setGmmCompanyCode(String[] gmmCompanyCode) {
		this.gmmCompanyCode = gmmCompanyCode;
	}

	public void setGmmDcDate(String[] gmmDcDate) {
		this.gmmDcDate = gmmDcDate;
	}

	public void setGmmDcInd(String[] gmmDcInd) {
		this.gmmDcInd = gmmDcInd;
	}

	public void setGmmDivision(String[] gmmDivision) {
		this.gmmDivision = gmmDivision;
	}

	public void setGmmLineNo(String[] gmmLineNo) {
		this.gmmLineNo = gmmLineNo;
	}

	public void setGmmUserCode(String[] gmmUserCode) {
		this.gmmUserCode = gmmUserCode;
	}

	public String[] getAccessTeamCode() {
		return accessTeamCode;
	}

	public void setAccessTeamCode(String[] accessTeamCode) {
		this.accessTeamCode = accessTeamCode;
	}


	////////////////////////////////////////////////////////////////////////////////
	//Other Accessors (get/set methods)
	////////////////////////////////////////////////////////////////////////////////
	
	public Iterator getDeptValues(){
		return this.getTemplate().getDeptValues(this.getCompanyCode());
	}
	
	public Iterator getUserDivisionValues() {
		return this.getTemplate().getCodeDetailsValues(new CodeHdrPk(this.getCompanyCode(), ProjectConstants.CD_CODE_DIV));
	}

	public Iterator getQaHandlerFlagValues(){
		return this.getTemplate().getCommonYesNoValues();
	}
	
	public Iterator getQcHandlerFlagValues(){
		return this.getTemplate().getCommonYesNoValues();
	}
	
	public Iterator getApproverFlagValues(){
		return this.getTemplate().getCommonYesNoValues();
	}	
	
	public Iterator getGmmFlagValues(){
		return this.getTemplate().getCommonYesNoValues();
	}

	public String[] getSignatureContentType() {
		return signatureContentType;
	}

	public void setSignatureContentType(String[] signatureContentType) {
		this.signatureContentType = signatureContentType;
	}

	public String[] getSignatureDcDate() {
		return signatureDcDate;
	}

	public void setSignatureDcDate(String[] signatureDcDate) {
		this.signatureDcDate = signatureDcDate;
	}

	public String[] getSignatureDcInd() {
		return signatureDcInd;
	}

	public void setSignatureDcInd(String[] signatureDcInd) {
		this.signatureDcInd = signatureDcInd;
	}

	public String[] getSignatureDescription() {
		return signatureDescription;
	}

	public void setSignatureDescription(String[] signatureDescription) {
		this.signatureDescription = signatureDescription;
	}

	public String[] getSignatureLineNo() {
		return signatureLineNo;
	}

	public void setSignatureLineNo(String[] signatureLineNo) {
		this.signatureLineNo = signatureLineNo;
	}

	public byte[] getSignatureSignature() {
		return signatureSignature;
	}

	public void setSignatureSignature(byte[] signatureSignature) {
		this.signatureSignature = signatureSignature;
	}

	public String[] getSignatureSignatureType() {
		return signatureSignatureType;
	}

	public void setSignatureSignatureType(String[] signatureSignatureType) {
		this.signatureSignatureType = signatureSignatureType;
	}	
    
	public String[] getAccessTeamStatus() {
		return accessTeamStatus;
	}

	public void setAccessTeamStatus(String[] accessTeamStatus) {
		this.accessTeamStatus = accessTeamStatus;
	}

	
    public String getHdrCompanyType() {
        return hdrCompanyType;
    }
    public void setHdrCompanyType(String companyType) {
        this.hdrCompanyType = companyType;
    }
    public String getHdrCustCode() {
        return hdrCustCode;
    }
    public void setHdrCustCode(String custCode) {
        this.hdrCustCode = custCode;
    }
    public String getHdrNtTeam() {
        return hdrNtTeam;
    }
    public void setHdrNtTeam(String ntTeam) {
        this.hdrNtTeam = ntTeam;
    }
    
    public Iterator getHdrCompanyTypeValues() {
        return this.getTemplate().getCompanyTypesValues();
    }


    public Iterator getHdrNtTeamValues() {
        return this.getTemplate().getCodeDetailsValues(new CodeHdrPk(this.getCompanyCode(), ProjectConstants.CD_CODE_NT_TEAM));
    }

	public String[] getAccessTeamDcDate() {
		return accessTeamDcDate;
	}

	public void setAccessTeamDcDate(String[] accessTeamDcDate) {
		this.accessTeamDcDate = accessTeamDcDate;
	}

	public String[] getAccessTeamDcInd() {
		return accessTeamDcInd;
	}

	public void setAccessTeamDcInd(String[] accessTeamDcInd) {
		this.accessTeamDcInd = accessTeamDcInd;
	}

	public String[] getBuyerCode() {
		return buyerCode;
	}

	public void setBuyerCode(String[] buyerCode) {
		this.buyerCode = buyerCode;
	}

	public String[] getBuyerDcDate() {
		return buyerDcDate;
	}

	public void setBuyerDcDate(String[] buyerDcDate) {
		this.buyerDcDate = buyerDcDate;
	}

	public String[] getBuyerDcInd() {
		return buyerDcInd;
	}

	public void setBuyerDcInd(String[] buyerDcInd) {
		this.buyerDcInd = buyerDcInd;
	}

	public String[] getBuyerStatus() {
		return buyerStatus;
	}

	public void setBuyerStatus(String[] buyerStatus) {
		this.buyerStatus = buyerStatus;
	}

	public String[] getBrandCode() {
		return brandCode;
	}

	public void setBrandCode(String[] brandCode) {
		this.brandCode = brandCode;
	}

	public String[] getBrandDcDate() {
		return brandDcDate;
	}

	public void setBrandDcDate(String[] brandDcDate) {
		this.brandDcDate = brandDcDate;
	}

	public String[] getBrandDcInd() {
		return brandDcInd;
	}

	public void setBrandDcInd(String[] brandDcInd) {
		this.brandDcInd = brandDcInd;
	}

	public String[] getBrandStatus() {
		return brandStatus;
	}

	public void setBrandStatus(String[] brandStatus) {
		this.brandStatus = brandStatus;
	}

	public String[] getNtTeamCode() {
		return ntTeamCode;
	}

	public void setNtTeamCode(String[] ntTeamCode) {
		this.ntTeamCode = ntTeamCode;
	}

	public String[] getNtTeamDcDate() {
		return ntTeamDcDate;
	}

	public void setNtTeamDcDate(String[] ntTeamDcDate) {
		this.ntTeamDcDate = ntTeamDcDate;
	}

	public String[] getNtTeamDcInd() {
		return ntTeamDcInd;
	}

	public void setNtTeamDcInd(String[] ntTeamDcInd) {
		this.ntTeamDcInd = ntTeamDcInd;
	}

	public String[] getNtTeamStatus() {
		return ntTeamStatus;
	}

	public void setNtTeamStatus(String[] ntTeamStatus) {
		this.ntTeamStatus = ntTeamStatus;
	}


}